import time

from selenium import webdriver
from selenium.webdriver.common.by import By
# 1、导入Select类
from selenium.webdriver.support.select import Select


driver = webdriver.Chrome()
driver.maximize_window()
driver.implicitly_wait(10)
driver.get("http://192.168.0.108/home/Index/index.html")
# 选择一个商品
driver.find_element(By.XPATH, '/html/body/div[4]/div[2]/div[2]/a[1]').click()
# 实例化select对象 select=Select(element)    # element对象表示的是select元素对象
element = driver.find_element(By.CSS_SELECTOR, '#dispatching_select')   # 注意只能选择select标签
select = Select(element)
# 通过select的相关方法选择option选项
select.select_by_index(1)  # ()内是下标

time.sleep(3)
driver.quit()